import os
import time
import random


def RandPosition(x, y, range=12):
    '根据输入的坐标和浮动范围生成一个随机坐标'
    _x = random.randint(x-range, x+range)
    _y = random.randint(y-range, y+range)
    return _x, _y


# 手机连上了才执行
if('device' in os.popen('adb devices').readlines()[1]):
    while(True):
        tX, tY = RandPosition(530, 1000)
        tTime = random.random()/10
        
        # 点猫
        os.system('adb shell input tap ' + str(tX) + ' ' + str(tY))
        print('点了' + str(tX) + ' ' + str(tY) + ' ' + str(tTime))
        time.sleep(tTime)
